#! /usr/bin/perl
# Copyright (C) 2001-2002 by <Christian.Queinnec@lip6.fr>
# $Id: test00.cgi,v 1.1 2004/02/21 18:48:08 ibo Exp $

use CGI qw(:standard :html3);
use CGI::Carp qw(fatalsToBrowser);
require "FOGE.pl";

my $testname = 'test00';

# Define some new questions (questions.pl lists questions in French:)

my @Beverage = ("Chocobeer", "Duff", "Duff Ultra", );
my @Food = ("Donut", "Pork Chop", "Hazelnut", "Cheesecake", );

CGI::FOGE2::add_questions
  ({
    favoriteFood => 
    {
     kind   => 'menu',
     label  => "What's your favorite food?",
     choice => \@Food
    },

    favoriteBeverage => 
    {
     kind   => 'menu',
     label  => "What's your favorite beverage?",
     choice => \@Beverage
    }
   });

# Define a first section with two questions

my @questions1 =
  (
   { id => 'favoriteFood', 'mandatory' => 1},
   { id => 'favoriteBeverage', },
  );

my $section1 = {
    'title' => "Food and Drugs", 
    'table' => 'foge_'.$testname.'_01',
    'questions' => \@questions1,
    'bof' => 1,
};

# Define a second section.
# (...)

# Define the whole form:

my @theSections = (
     $section1,
);

$forms = {
    'title'   => "CGI::FOGE2: $testname",
    # 'css'     => "t.css",
    # 'author'     => "Christian.Queinnec@lip6.fr",
    'enquiry' => 'foge_'.$testname.'_answer',
    'introduction' => "
This CGI form is a running example for FOGE. Fill it, submit it, 
then look at the <a href=\"$testname.cgi/see\">statistical results</a>.
<p> Mandatory questions are marked with a red star.
",
    'conclusion'   => "This form is run by FOGE (and Perl and CGI).",
    'ipMask'       => '.*', # only accepted IP number
    'submit'       => "Hop!",
    'sets' => \@theSections,
    'acknowledgment' => 'Tanks for you corporations',
    'pageFooter' => '<br><tt>
$Id: test00.cgi,v 1.1 2004/02/21 18:48:08 ibo Exp $
</tt><br>
',
    # Time management
    #'formEndTime'   => $formEndTime,
    #'statStartTime' => $statStartTime,
    # SQL data base to be used:
    'dbName'         => 'dbi:Pg:dbname=foge host=localhost',
    'dbReaderName'   => 'test_foge_r',
    'dbReaderPW'     => 'test_foge_pwr',
    'dbWriterName'   => 'test_foge_w',
    'dbWriterPW'     => 'test_foge_pww',

     dbReaderLogin  => "test_foge_r",
     dbWriterLogin  => "test_foge_w",
     dbReaderPass   => "test_foge_pwr",
     dbWriterPass   => "test_foge_pww",

    # Vote key management:
    #'dbKeyTable'     => 'finsemestre_key',
    #'keyName'        => 'finsemestre_key', # dbKeyTable by default
    #'keyPrologue'    => "<center><p>",
    #'keyEpilogue'    => "</center></p>",
    # URL password (Statistics may only be seen before being public 
    # if knowing this password
    #'URLpw' => 'IYFV5',
    'year'  =>  2003,
    'ignoreLag' => 0,
};

# Handle GET or POST requests:
#   http://.../sample.cgi                       will serve the form
#   http://.../sample.cgi/anotherSecretePW/see  will serve the statistics
#   perl ./sample.cgi 'action=genererTablesEnvoyer' > tables.sql
#                      will generate the SQL tables.

CGI::FOGE2::default_main($forms);

1;

# end of foge-sample.cgi
